{# Current team box #}
<div class="content">
    <h1>Manage Team For: {{ gradeable.getTitle() }}</h1>
    {# Team lock message #}
    {% if lock %}
        {% if team %}
            <p class="red-message">
                Teams are now locked for this assignment.<br>
                Contact your instructor to make changes to your team.
            </p><br />
        {% else %}
            <p class="red-message">
                Teams are now locked for this assignment.<br>
                You can create a new team of 1 or accept an invitation sent before teams were locked.<br>
                Contact your instructor to make further changes to your team.
            </p><br />
        {% endif %}
    {% endif %}
    {# /Team lock message #}

    {% if team %}
        {# Top content box, has team #}
        <h3>Your Team:</h3> <br />

        {# List team members #}
        {% for teammate in members %}
            <span>&emsp;{{ teammate.getDisplayedFirstName() }} {{ teammate.getDisplayedLastName() }} ({{ teammate.getId() }}) - {{ teammate.getEmail() }}</span> <br />
        {% endfor %}

        {# Team invitations status #}
        {% if team.getInvitations()|length != 0 %}
            <br />
            <h3>Pending Invitations:</h3> <br />

            {% for invited in team.getInvitations() %}
                {% if lock %}
                    <span>&emsp;{{ invited }}</span> <br />
                {% else %}
                    <form action="{{ cancel_invitation_url }}" method="post">
                        <input type="hidden" name="cancel_id" value={{ invited }} />
                        <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
                        &emsp;{{ invited }}: <input type="submit" value = "Cancel" class="btn btn-danger" />
                    </form>
                    <br />
                {% endif %} {# lock #}
            {% endfor %} {# invited in invitations #}
        {% endif %} {# invitations.length #}
        {# /Team invitations status #}

        {# Repository status #}
        {% if gradeable.isVcs() %}
            <br />
            <h3>To access your Team Repository:</h3>
            <span>
                <em>Note: There may be a delay before your repository is prepared, please refer to assignment instructions.</em>
                    <br />
                    <br />
                <samp>git clone {{ gradeable.getRepositoryPath(user, team) }} SPECIFY_TARGET_DIRECTORY</samp>
            <br />
            </span>
            <br />
        {% endif %}
        {# /Repository status #}

    {% else %} {# team #}
        {# Top content box, no team #}
        <h4>You are not on a team.</h4> <br />
    {% endif %} {# team #}
</div>
{# /Current team box #}

{# Edit/create team box #}
{% if team and not lock %}
    {# Bottom content box, has team, teams not locked #}
    <div class="content">
        <h3>Invite new teammates by their user ID:</h3>
        <br />
        <form action="{{ send_invitation_url }}" method="post">
            <input type="text" name="invite_id" id="invite_id" placeholder="User ID" />
            <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
            <input type="submit" value = "Invite" class="btn btn-primary" />
        </form>
        <br />
        <button class="btn btn-danger" onclick="location.href='{{ leave_team_url }}'">Leave Team</button>
    </div>
{% elseif team == null %}
    <div class="content">
        {% if invites_received|length == 0 %}
            <h4>You have not received any invitations.</h4> <br />
        {% else %}
            <h3>Invitations:</h3> <br />

            {% for invite in invites_received %}
                <form action="{{ accept_invitation_url }}" method="post">
                    <input type="hidden" name="team_id" value={{ invite.getId() }} />
                    <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
                    &emsp;{{  invite.getMemberList() }}: <input type="submit" value = "Accept" class="btn btn-success" />
                </form>
                <br />
            {% endfor %} {# invite in received #}
        {% endif %} {# invites length == 0 #}

        {# Create new team button #}
        <br />
        <button class="btn btn-primary" onclick="location.href='{{ create_team_url }}'">Create New Team </button>

        {% if seeking_partner %}
            <button class="btn btn-danger" onclick="location.href='{{ stop_seek_url }}'">Stop Seeking Team/Partner </button>
        {% else %}
            &nbsp;or&nbsp;<button class="btn btn-primary" onclick="location.href='{{ seek_url }}'">Seek Team/Partner </button>
        {% endif %}
    </div>
{% endif %}
{# /Edit/create team box #}

{# Users seeking team box #}
<div class="content">
    <div style="width:60%;">
        <h3>Users Seeking Team/Partner:</h3><br />
        {# This is a data table #}
        <table class="table table-striped table-bordered persist-area">
            <caption />
            <thead class="persist thead">
                <tr>
                    <th width="3%"></th>
                    <th width="10%">First Name</th>
                    <th width="10%">Last Name</th>
                    <th width="10%">User ID</th>
                    <th width="40%">Email</th>
                </tr>
            </thead>
            <tbody>
                {% for user_details in seekers %}
                    <tr>
                        <td>{{ loop.index }}</td>
                        <td>{{ user_details.getDisplayedFirstName() }}</td>
                        <td>{{ user_details.getDisplayedLastName() }}</td>
                        <td>{{ user_details.getId() }}</td>
                        <td>{{ user_details.getEmail() }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
